package com.sdtele.tta.models;

import java.sql.Date;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;


public class Task {
	private long id;
	private long ownerId;
	private String title;
	private String description;
	private Timestamp createTime;
	private Date deadLine;
	private long emergency;
	private long fatherTaskId;
	private int completion;
	private long state;
	private String tags;
	private Timestamp updateTime;
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public long getOwnerId() {
		return ownerId;
	}
	public void setOwnerId(long ownerId) {
		this.ownerId = ownerId;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Timestamp getCreateTime() {

		return createTime;
	}
	public void setCreateTime(Timestamp creatTime) {
		this.createTime = creatTime;
	}
	public Date getDeadLine() {
		return deadLine;
	}
	public void setDeadLine(Date deadLine) {
		this.deadLine = deadLine;
	}
	public long getEmergency() {
		return emergency;
	}
	public void setEmergency(long emergency) {
		this.emergency = emergency;
	}
	public long getFatherTaskId() {
		return fatherTaskId;
	}
	public void setFatherTaskId(long fatherTaskId) {
		this.fatherTaskId = fatherTaskId;
	}
	public int getCompletion() {
		return completion;
	}
	public void setCompletion(int completion) {
		this.completion = completion;
	}
	public long getState() {
		return state;
	}
	public void setState(long state) {
		this.state = state;
	}
	public String getTags() {
		return tags;
	}
	public void setTags(String tags) {
		this.tags = tags;
	}
	public Timestamp getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Timestamp updateTime) {
		this.updateTime = updateTime;
	}
	
	public TaskOut ToTaskOut() 
	{
		TaskOut taskOut = new TaskOut();
		taskOut.setId(id);
		taskOut.setOwnerId(ownerId);
		taskOut.setState(state);
		taskOut.setTags(tags);
		taskOut.setTitle(title);
		taskOut.setFatherTaskId(fatherTaskId);
		taskOut.setEmergency(emergency);
		taskOut.setDescription(description);
		taskOut.setCompletion(completion);

	
		DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
		DateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); 
		taskOut.setCreateTime(sdf.format(createTime));
		taskOut.setUpdateTime(sdf.format(updateTime));
		if(deadLine != null)
		taskOut.setDeadLine(sdf1.format(deadLine));
		else
			taskOut.setDeadLine("");
		return taskOut;
		
	}
	@Override
	public String toString() {
		return "Task [id=" + id + ", ownerId=" + ownerId + ", title=" + title + ", description=" + description
				+ ", creatTime=" + createTime + ", deadLine=" + deadLine + ", emergency=" + emergency + ", fatherTaskId="
				+ fatherTaskId + ", completion=" + completion + ", state=" + state + ", tags=" + tags + ", updateTime="
				+ updateTime + "]";
	}	
	
}
